<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dashboard extends MY_Controller {

	/**
         * 管理后台的首页
	 */
	public function index()
	{
            
            $if_login = $this->session->has_userdata('admin');
            
            if(!$if_login)
            {
                redirect('Dashboard/login');
                exit();
                
                
            }
            else
            {
                //加载公共视图
                
                
                $header = $this->parser->parse("Common/header",$this->data_package,TRUE);
                $navigation = $this->parser->parse("Common/navigation",$this->data_package,TRUE);
                $footer = $this->parser->parse("Common/footer",$this->data_package,TRUE);
    //            
    //            
                $site_info['header'] = $header;
                $site_info['navigation']=$navigation;
                $site_info['footer'] = $footer;

                
                
//                print_r($site_info);
//                exit();


                $this->data_package=array_merge($this->data_package,$site_info);

                $this->parser->parse('Dashboard/dashboard',$this->data_package);
            }
            
            
            


	}
        
        
        /*
         * 辅助
         */
        public function login() {
            
            
            if($_POST)
            {
                /*
                 * 提交上来的数据要做判断
                 */
                $username = $this->input->post("username");
                $password = $this->input->post("password");
                
                if($username=="admin" && $password=="admin")
                {
                    $_SESSION['admin'] = "admin";
                    redirect("Dashboard/index");
                    
                }
                else
                {
                    redirect('Dashboard/login');
                }
                
                
            }
            else
            {
                $this->parser->parse('Dashboard/login',$this->data_package);
            }
            
        }
        
        
        
        /*
         * 推送短信
         */
        public function test2() {
            $this->config->load('config_diy',TRUE);
            $configs['appkey']=$this->config->item('appkey','config_diy');
            $configs['secretKey']=$this->config->item('secretKey','config_diy');
            // print_r($configs);
            
            // exit();
            // $configs['appkey']="23332279";
            // $configs['secretKey']="300852f85ff0af53b397ab0c76d4022b";
            
//            加载发送短信的类
            $this->load->library("alidayu",$configs);
            
            
            /*
             * 
             * 发送短信
             * 
             * 编辑好发送的内容内容
             * 
             */
            
            $this->alidayu->sendsms();
        }
}
